package org.azmat.demojpa.Controller.JPA;

import org.azmat.demojpa.SQL.JPA.Service.ClassesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.servlet.ModelAndView;

@Controller
public class ClassesController {

    @Autowired
    private ClassesService classesService;

    @GetMapping("/classesList")
    public ModelAndView findAllClasses(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("classesList", classesService.findAllClasses());
        modelAndView.setViewName("classesList");
        return modelAndView;
    }
}
